package model;

import java.util.ArrayList;

/***
 * Class which represents a class with attributes, methods and parent.
 * @author Federico
 *
 */
public class Class {
	
	private String name;
	private String parent;
	private ArrayList<Method> methods;
	private ArrayList<Attribute> attributes;
	
	public Class(){
		methods = new ArrayList<Method>();
		attributes = new ArrayList<Attribute>();
	}
	
	public Class(String n){
		name = n;
		methods = new ArrayList<Method>();
		attributes = new ArrayList<Attribute>();
	}
	
	public boolean hasParent(){
		return parent!=null;
	}
	
	public void addMethod(Method m){
		methods.add(m);
	}
	
	public void addAttribute(Attribute a){
		attributes.add(a);
	}
	
	public void addAttribute(String n){
		attributes.add(new Attribute(n));
	}

	public String getName() {
		return name;
	}

	public String getParent() {
		return parent;
	}

	public ArrayList<Method> getMethods() {
		return methods;
	}

	public ArrayList<Attribute> getAttributes() {
		return attributes;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setParent(String parent) {
		this.parent = parent;
	}

	public void setMethods(ArrayList<Method> methods) {
		this.methods = methods;
	}

	public void setAttributes(ArrayList<Attribute> attributes) {
		this.attributes = attributes;
	}
	
	public String toString(){
		String toRet = "New Object: \n";
		toRet+="\tName: "+name;
		toRet+="\n\tParent: "+parent;
		if(!attributes.isEmpty())
			for(Attribute a: attributes)
				toRet+="\n\t\t"+a.toString();
		if(!methods.isEmpty())
			toRet+="\n";
			for(model.Method m : methods)
				toRet+="\t\t"+m.toString()+"\n";
		return toRet;
	}
}
